/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/**
 * @Title: ParseImage.java
 * @Package phoenics.apeak.simple.service
 * @Description
 * @author phoenics@126com
 * @date 2016-1-30 16:01:31
 * @version V1.0
 */
package phoenics.apeak.simple.service;

import java.util.Base64;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import phoenics.apeak.crawl.Extractor;
import phoenics.apeak.crawl.service.DocumentPublisher;
import phoenics.apeak.simple.entity.Image;
import phoenics.apeak.simple.store.ImageDao;
// TODO: Auto-generated Javadoc

/**
 * The Class ParseImage.
 *
 * @Description The Class ParseImage.
 */
@Service
public class ParseImage implements Extractor{
	/** The image dao. */
	@Autowired
	ImageDao  imageDao;
	
	/** The document publisher. */
	@Autowired
	DocumentPublisher documentPublisher;
	
	/** The url. */
	private String url;
	
	/* (non-Javadoc)
	 * @see phoenics.apeak.crawl.Extractor#extract(byte[])
	 */
	@Override
	public void extract(byte[] content) {
		Image image=new Image();
		image.setUrl(url);
		image.setContent(Base64.getEncoder().encodeToString(content));
		imageDao.save(image);
	}
	
	/**
 * Gets the url.
 *
 * @return the url
 */
	public String getUrl() {
		return url;
	}
	
	/* (non-Javadoc)
	 * @see phoenics.apeak.crawl.Extractor#setUrl(java.lang.String)
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	
	/* (non-Javadoc)
	 * @see phoenics.apeak.crawl.Extractor#setParams(java.lang.String)
	 */
	@Override
	public void setParams(String params) {
		// TODO Auto-generated method stub
		
	}
	/*@Override
	public DataType getDataType(){
		return DataType.IMAGE;
	}*/

}
